#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

struct ListNode {
    int val;
    ListNode* next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode* next) : val(x), next(next) {}
};

ListNode* swapPairs(ListNode* head) {
    auto nhead = new ListNode(-1);
    nhead->next = head;
    auto prev = nhead, cur = head;
    while (cur && cur->next)
    {
        auto next = cur->next;
        cur->next = next->next;
        prev->next = next;
        auto nnext = next->next;
        next->next = cur;
        prev = cur;
        cur = nnext;
    }
    return nhead->next;
}

vector<vector<int>> combinationSum(vector<int>& c, int target) {
    vector<vector<int>> res;
    auto dfs = [&](auto&& dfs, int u, int tot, vector<int>& st) {
        if (u == c.size())   return;
        if (tot == 0)
        {
            res.push_back(st);
            return;
        }
        dfs(dfs, u + 1, tot, st);
        if (tot >= c[u])
        {
            st.push_back(c[u]);
            dfs(dfs, u, tot - c[u], st);
            st.pop_back();
        }
    };

    vector<int> st;
    dfs(dfs, 0, target, st);

    return res;
}